#include <gtest/gtest.h>

#include <iostream>
#include <unordered_map>

class MyEnvironment: public testing::Environment
{
public:
    virtual void SetUp() override
    {
        std::cout << "单元测试执行前的环境初始化!\n";
    }
    virtual void TearDown() override
    {
        std::cout << "单元测试执行后的环境清理!\n";
    }
};

TEST(MyEnvironment, test1)
{
    std::cout << "单元测试1\n";
}

TEST(MyEnvironment, test2)
{
    std::cout << "单元测试2\n";
}

class MyTest: public testing::Test
{
public:
    static void SetUpTestCase()
    {
        std::cout << "所有单元测试执行前，初始化总环境！\n";
    }
    static void TearDownTestCase()
    {
        std::cout << "所有单元测试执行后，清理总环境！\n";
    }
public:
    std::unordered_map<std::string, std::string> _mymap;
};

TEST_F(MyTest, insert_test)
{
    _mymap.insert(std::make_pair("hello", "你好"));
    _mymap.insert(std::make_pair("bye", "拜拜"));
}

TEST_F(MyTest, size_test)
{
    ASSERT_EQ(_mymap.size(), 2);
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    testing::AddGlobalTestEnvironment(new MyEnvironment);
    RUN_ALL_TESTS();

    return 0;
}